package com.oa.admin.result;


import com.joneying.common.annotation.CommonController;
import com.joneying.common.web.response.Resp;
import com.oa.admin.dto.*;
import com.oa.admin.entity.Key;
import com.oa.admin.service.*;
import com.oa.admin.vo.FixedAssetsUpdateDTO;
import com.oa.core.BaseController;
import com.oa.core.exception.BusinessException;
import com.oa.core.exception.DataIsEmptyException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.context.annotation.Description;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/itemmanagement")
@Api(description = "行政管理-物品管理")
public class ItemManagementController extends BaseController {

    private final IFixedAssetsService fixedAssetsService;
    private final ICarService carService;
    private final IHouseService houseService;
    private final IMonitoringService monitoringService;
    private final IDormService dormService;
    private final IUsingApplicationService usingApplicationService;
    private final ISealService sealService;
    private final IKeyService keyService;


    public ItemManagementController(IFixedAssetsService fixedAssetsService, ICarService carService, IHouseService houseService, IMonitoringService monitoringService, IDormService dormService, IUsingApplicationService usingApplicationService, ISealService sealService, IKeyService keyService) {
        this.fixedAssetsService = fixedAssetsService;
        this.carService = carService;
        this.houseService = houseService;
        this.monitoringService = monitoringService;
        this.dormService = dormService;
        this.usingApplicationService = usingApplicationService;
        this.sealService = sealService;
        this.keyService = keyService;
    }


    @PostMapping("/addFixedAssets")
    @CommonController
    @Description("固定资产管理-新增固定资产")
    @ApiOperation(value = "固定资产管理-新增固定资产")
    public Resp addFixedAssets(@ApiParam(value = "固定资产表对象") @RequestBody(required = false) FixedAssetsAddDTO fixedAssetsAddDTO) throws BusinessException {
        return fixedAssetsService.addFixedAssets(fixedAssetsAddDTO);
    }

    @PostMapping("/findFixedAssetsListCondition")
    @CommonController
    @Description("固定资产管理-根据条件查询固定资产")
    @ApiOperation(value = "固定资产管理-根据条件查询固定资产")
    public Resp findFixedAssetsListCondition(@ApiParam(value = "条件查询对象") @RequestBody(required = false) FixedAssetsConditionDTO fixedAssetsConditionDTO) throws DataIsEmptyException {
        return new Resp().success(fixedAssetsService.findFixedAssetsListCondition(fixedAssetsConditionDTO));
    }

    @PostMapping("/findFixedAssetsType")
    @CommonController
    @Description("固定资产管理-查询资产类别")
    @ApiOperation(value = "固定资产管理-查询资产类别")
    public Resp findFixedAssetsType() throws DataIsEmptyException {
        return fixedAssetsService.findFixedAssetsType();
    }


    @PostMapping("/findFixedAssetsDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id查询资产详情")
    @ApiOperation(value = "固定资产管理-根据主键id查询资产详情")
    public Resp findFixedAssetsDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws DataIsEmptyException {
        return fixedAssetsService.findFixedAssetsDetailsById(id);
    }

    @PostMapping("/updateFixedAssetsById")
    @CommonController
    @Description("固定资产管理-根据主键id修改资产")
    @ApiOperation(value = "固定资产管理-根据主键id修改资产")
    public Resp updateFixedAssetsById(@ApiParam(value = "资产修改对象") @RequestBody(required = false) FixedAssetsUpdateDTO fixedAssetsUpdateDTO) throws BusinessException {
        return fixedAssetsService.updateFixedAssetsById(fixedAssetsUpdateDTO);
    }

    @PostMapping("/deleteFixedAssets")
    @CommonController
    @Description("固定资产管理-根据主键id删除资产")
    @ApiOperation(value = "固定资产管理-根据主键id删除资产")
    public Resp deleteFixedAssets(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException, DataIsEmptyException {
        return fixedAssetsService.deleteFixedAssets(id);
    }


    @GetMapping("/exportFixedAssetsList")
    @CommonController
    @Description("固定资产管理-导出资产列表")
    @ApiOperation(value = "固定资产管理-导出资产列表")
    public Resp exportFixedAssetsList() throws DataIsEmptyException, BusinessException {
        return fixedAssetsService.exportFixedAssetsList();
    }


    @PostMapping("/addCar")
    @CommonController
    @Description("固定资产管理-新增车辆")
    @ApiOperation(value = "固定资产管理-新增车辆")
    public Resp addCar(@ApiParam(value = "车辆对象") @RequestBody(required = false) CarAddDTO carAddDTO) throws BusinessException {
        return carService.addCar(carAddDTO);
    }

    @PostMapping("/findCarListByCondition")
    @CommonController
    @Description("固定资产管理-根据条件查询车辆列表")
    @ApiOperation(value = "固定资产管理-根据条件查询车辆列表")
    public Resp findCarListByCondition(@ApiParam(value = "查询条件对象") @RequestBody(required = false) CarConditionDTO carConditionDTO) throws DataIsEmptyException {
        return new Resp().success(carService.findCarListByCondition(carConditionDTO));
    }


    @PostMapping("/findCarDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id查询车辆详情")
    @ApiOperation(value = "固定资产管理-根据主键id查询车辆详情")
    public Resp findCarDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) {
        return carService.findCarDetailsById(id);
    }

    @PostMapping("/updateCarDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id修改车辆详细信息")
    @ApiOperation(value = "固定资产管理-根据主键id修改车辆详细信息")
    public Resp updateCarDetailsById(@ApiParam(value = "车辆修改对象") @RequestBody(required = false) CarUpdateDTO carUpdateDTO) throws BusinessException {
        return carService.updateCarDetailsById(carUpdateDTO);
    }


    @PostMapping("/carMaintain")
    @CommonController
    @Description("固定资产管理-车辆维修/保养")
    @ApiOperation(value = "固定资产管理-车辆维修/保养")
    public Resp carMaintain(@ApiParam(value = "车辆维修对象") @RequestBody(required = false) CarMaintatainDTO carMaintatainDTO) throws BusinessException {
        return carService.carMaintain(carMaintatainDTO);
    }


    @PostMapping("/updateCarStatusNormal")
    @CommonController
    @Description("固定资产管理-修改车辆状态为正常")
    @ApiOperation(value = "固定资产管理-修改车辆状态为正常")
    public Resp updateCarStatusNormal(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException {
        return carService.updateCarStatusNormal(id);
    }

    @GetMapping("/exportCarList")
    @CommonController
    @Description("固定资产管理-导出车辆列表")
    @ApiOperation(value = "固定资产管理-导出车辆列表")
    public Resp exportCarList() throws BusinessException, DataIsEmptyException {
        return carService.exportCarList();
    }


    @PostMapping("/addHouse")
    @CommonController
    @Description("固定资产管理-新增房屋")
    @ApiOperation(value = "固定资产管理-新增房屋")
    public Resp addHouse(@ApiParam(value = "房屋对象") @RequestBody(required = false) HouseAddDTO houseAddDTO) throws BusinessException {
        return houseService.addHouse(houseAddDTO);
    }


    @PostMapping("/findHouseListByCondition")
    @CommonController
    @Description("固定资产管理-根据条件查询房屋列表")
    @ApiOperation(value = "固定资产管理-根据条件查询房屋列表")
    public Resp findHouseListByCondition(@ApiParam(value = "房屋查询条件对象") @RequestBody(required = false) HouseConditionDTO houseConditionDTO) throws BusinessException, DataIsEmptyException {
        return new Resp().success(houseService.findHouseListByCondition(houseConditionDTO));
    }

    @PostMapping("/findHouseDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id查询房屋详情")
    @ApiOperation(value = "固定资产管理-根据主键id查询房屋详情")
    public Resp findHouseDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) {
        return houseService.findHouseDetailsById(id);
    }

    @PostMapping("/updateHouseDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id编辑房屋信息")
    @ApiOperation(value = "固定资产管理-根据主键id编辑房屋信息")
    public Resp updateHouseDetailsById(@ApiParam(value = "房屋修改对象") @RequestBody(required = false) HouseUpdateDTO houseUpdateDTO) throws BusinessException {
        return houseService.updateHouseDetailsById(houseUpdateDTO);
    }

    @PostMapping("/deleteHouseDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id删除房屋信息")
    @ApiOperation(value = "固定资产管理-根据主键id删除房屋信息")
    public Resp deleteHouseDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException {
        return houseService.deleteHouseDetailsById(id);
    }

    @GetMapping("/exportHouseList")
    @CommonController
    @Description("固定资产管理-导出房屋租赁列表")
    @ApiOperation(value = "固定资产管理-导出房屋租赁列表")
    public Resp exportHouseList() throws BusinessException, DataIsEmptyException {
        return houseService.exportHouseList();
    }


    @PostMapping("/addMonitoring")
    @CommonController
    @Description("固定资产管理-新增监控")
    @ApiOperation(value = "固定资产管理-新增监控")
    public Resp addMonitoring(@ApiParam(value = "监控对象") @RequestBody(required = false) MonitoringAddDTO monitoringAddDTO) throws BusinessException {
        return monitoringService.addMonitoring(monitoringAddDTO);
    }


    @PostMapping("/findMonitoringListByCondition")
    @CommonController
    @Description("固定资产管理-根据条件查询监控列表")
    @ApiOperation(value = "固定资产管理-根据条件查询监控列表")
    public Resp findMonitoringListByCondition(@ApiParam(value = "页码") @RequestParam(required = false) Integer page,
                                              @ApiParam(value = "查询条数") @RequestParam(required = false) Integer limit) throws BusinessException, DataIsEmptyException {
        return new Resp().success(monitoringService.findMonitoringListByCondition(page, limit));

    }

    @PostMapping("/findMonitoringDetailsById")
    @CommonController
    @Description("固定资产管理-根据id查询监控详情")
    @ApiOperation(value = "固定资产管理-根据id查询监控详情")
    public Resp findMonitoringDetailsById(@ApiParam(value = "id", required = true) @RequestParam String id) throws DataIsEmptyException {
        return monitoringService.findMonitoringDetailsById(id);
    }


    @PostMapping("/updatMonitoringDetailsById")
    @CommonController
    @Description("固定资产管理-根据id编辑监控")
    @ApiOperation(value = "固定资产管理-根据id编辑监控")
    public Resp updatMonitoringDetailsById(@ApiParam(value = "监控编辑对象") @RequestBody(required = false) MonitoringUpdateDTO monitoringUpdateDTO) throws DataIsEmptyException, BusinessException {
        return monitoringService.updatMonitoringDetailsById(monitoringUpdateDTO);
    }


    @GetMapping("/exportMonitoringList")
    @CommonController
    @Description("固定资产管理-导出监控列表")
    @ApiOperation(value = "固定资产管理-导出监控列表")
    public Resp exportMonitoringList() throws BusinessException, DataIsEmptyException {
        return monitoringService.exportMonitoringList();
    }


    @PostMapping("/addDorm")
    @CommonController
    @Description("固定资产管理-提交宿舍申请")
    @ApiOperation(value = "固定资产管理-提交宿舍申请")
    public Resp addDorm(@ApiParam(value = "宿舍申请对象") @RequestBody(required = false) DormAddDTO dormAddDTO) throws BusinessException, DataIsEmptyException {
        return dormService.addDorm(getLoginUserId(),dormAddDTO);
    }


    @PostMapping("/findDormListByCondition")
    @CommonController
    @Description("固定资产管理-根据条件查询宿舍申请")
    @ApiOperation(value = "固定资产管理-根据条件查询宿舍申请")
    public Resp findDormListByCondition(@ApiParam(value = "宿舍条件查询对象") @RequestBody(required = false) DormConditionDTO dormConditionDTO) throws BusinessException, DataIsEmptyException {
        return new Resp().success(dormService.findDormListByCondition(dormConditionDTO));
    }


    @PostMapping("/findDormDetailsById")
    @CommonController
    @Description("固定资产管理-根据id查询宿舍申请详情")
    @ApiOperation(value = "固定资产管理-根据id查询宿舍申请详情")
    public Resp findDormDetailsById(@ApiParam(value = "id", required = true) @RequestParam String id) throws BusinessException, DataIsEmptyException {
        return dormService.findDormDetailsById(id);
    }


    @PostMapping("/dormApproval")
    @CommonController
    @Description("固定资产管理-宿舍申请审批(审批后)")
    @ApiOperation(value = "固定资产管理-宿舍申请审批(审批后)")
    public Resp dormApproval(@ApiParam(value = "宿舍审批对象") @RequestBody(required = false) DormApprovalDTO dormApprovalDTO) throws BusinessException, DataIsEmptyException {
        return dormService.dormApproval(dormApprovalDTO);
    }


    @GetMapping("/exportDormApplicationList")
    @CommonController
    @Description("固定资产管理-导出宿舍申请列表")
    @ApiOperation(value = "固定资产管理-导出宿舍申请列表")
    public Resp exportDormApplicationList() throws BusinessException {
        return dormService.exportDormApplicationList();
    }


    @PostMapping("/addUsingApplication")
    @CommonController
    @Description("固定资产管理-提交用印申请")
    @ApiOperation(value = "固定资产管理-提交用印申请")
    public Resp addUsingApplication(@ApiParam(value = "用印申请对象") @RequestBody(required = false) UsingApplicationAddDTO usingApplicationAddDTO) throws BusinessException, DataIsEmptyException {
        return usingApplicationService.addUsingApplication(usingApplicationAddDTO);
    }


    @PostMapping("/findUsingApplicationListVoByCondition")
    @CommonController
    @Description("固定资产管理-根据条件查询用印申请")
    @ApiOperation(value = "固定资产管理-根据条件查询用印申请")
    public Resp findUsingApplicationListVoByCondition(@ApiParam(value = "用印申请条件对象") @RequestBody(required = false) UsingApplicationConditionDTO usingApplicationConditionDTO) throws DataIsEmptyException, BusinessException {
        return new Resp().success(usingApplicationService.findUsingApplicationListVoByCondition(usingApplicationConditionDTO));

    }


    @PostMapping("/findUsingApplicationDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id查询用印申请详情")
    @ApiOperation(value = "固定资产管理-根据主键id查询用印申请详情")
    public Resp findUsingApplicationDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException, DataIsEmptyException {
        return usingApplicationService.findUsingApplicationDetailsById(id);
    }


    @GetMapping("/exportUsingApplicationList")
    @CommonController
    @Description("固定资产管理-导出用印申请列表")
    @ApiOperation(value = "固定资产管理-导出用印申请列表")
    public Resp exportUsingApplicationList() throws BusinessException, DataIsEmptyException {
        return usingApplicationService.exportUsingApplicationList();
    }


    @PostMapping("/addSeal")
    @CommonController
    @Description("固定资产管理-添加公章")
    @ApiOperation(value = "固定资产管理-添加公章")
    public Resp addSeal(@ApiParam(value = "公章对象") @RequestBody(required = false) SealAddDTO sealAddDTO) throws BusinessException, DataIsEmptyException {
        return sealService.addSeal(getLoginUserId(), sealAddDTO);
    }


    @PostMapping("/updateSeal")
    @CommonController
    @Description("固定资产管理-修改公章")
    @ApiOperation(value = "固定资产管理-修改公章")
    public Resp updateSeal(@ApiParam(value = "公章修改对象") @RequestBody(required = false) SealUpdateDTO sealUpdateDTO) throws BusinessException, DataIsEmptyException {
        return sealService.updateSeal(sealUpdateDTO);
    }

    @PostMapping("/deleteSeal")
    @CommonController
    @Description("固定资产管理-根据主键id删除公章")
    @ApiOperation(value = "固定资产管理-根据主键id删除公章")
    public Resp deleteSeal(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException, DataIsEmptyException {
        return sealService.deleteSeal(id);
    }


    @PostMapping("/findSealList")
    @CommonController
    @Description("固定资产管理-查询公章列表")
    @ApiOperation(value = "固定资产管理-查询公章列表")
    public Resp findSealList(@ApiParam(value = "页码") @RequestParam(required = false) Integer page,
                             @ApiParam(value = "条数") @RequestParam(required = false) Integer limit) throws BusinessException, DataIsEmptyException {
        return new Resp().success(sealService.findSealList(page, limit));
    }


    @PostMapping("/findSealDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id查询公章详情")
    @ApiOperation(value = "固定资产管理-根据主键id查询公章详情")
    public Resp findSealDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException, DataIsEmptyException {
        return sealService.findSealDetailsById(id);
    }


    @PostMapping("/addKeys")
    @CommonController
    @Description("固定资产管理-添加钥匙")
    @ApiOperation(value = "固定资产管理-添加钥匙")
    public Resp addKeys(@ApiParam(value = "钥匙对象") @RequestBody(required = false) KeyAddVO keyAddVO) throws BusinessException, DataIsEmptyException {
        return keyService.addKeys(keyAddVO);
    }


    @PutMapping("/updateKeys")
    @CommonController
    @Description("固定资产管理-根据id修改钥匙")
    @ApiOperation(value = "固定资产管理-根据id修改钥匙")
    public Resp updateKeys(@ApiParam(value = "钥匙修改对象") @RequestBody(required = false) KeyUpdateVO keyUpdateVO) throws BusinessException {
        return keyService.updateKeys(keyUpdateVO);
    }


    @PostMapping("/findKeysList")
    @CommonController
    @Description("固定资产管理-查询钥匙列表")
    @ApiOperation(value = "固定资产管理-查询钥匙列表")
    public Resp findKeysList(@ApiParam(value = "页码") @RequestParam(required = false) Integer page,
                             @ApiParam(value = "条数") @RequestParam(required = false) Integer limit) throws BusinessException, DataIsEmptyException {
        return new Resp().success(keyService.findKeysList(page, limit));
    }

    @PostMapping("/findKeysDetailsById")
    @CommonController
    @Description("固定资产管理-根据主键id查询钥匙详情")
    @ApiOperation(value = "固定资产管理-根据主键id查询钥匙详情")
    public Resp findKeysDetailsById(@ApiParam(value = "主键id", required = true) @RequestParam String id) throws BusinessException, DataIsEmptyException {
        return keyService.findKeysDetailsById(id);
    }


}
